package edu.gu.hajo.gcl.cmd.impl;

import edu.gu.hajo.gcl.exception.ExecException;
import edu.gu.hajo.gcl.interp.IInterpreter;

/**
 * Todo lot of checking
 * @author hajo
 *
 */
public final class IncrCmd extends AbstractCmd{
	
	public IncrCmd(IInterpreter interp) {
		super(interp);
	}

	@Override
	public /*String*/ void execute( /*IInterpreter interp*/) {
		if (args.size() != 1) {
			throw new ExecException("Incr: Wrong # args");
		}

		String value = interp.getVar( args.get(0) );
		if( value == null ){
			throw new ExecException("Incr: Variable not found");
		}
		int ivalue = Integer.valueOf(value) + 1;
		interp.setVar(args.get(0), String.valueOf(ivalue));
		interp.setResult(String.valueOf(ivalue));
		//return value;
	}

}
